package com.imoblife.brainwavestus;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.util.Log;

public class ActivityBuffer {

	List<BaseActivity> _bufferList;

	private static ActivityBuffer _activityBuffer;

	public static ActivityBuffer getInstance() {

		if (_activityBuffer == null) {
			_activityBuffer = new ActivityBuffer();
		}

		return _activityBuffer;

	}

	private ActivityBuffer() {
		_bufferList = new ArrayList<BaseActivity>();
	}

	public void addActivity(BaseActivity basicActivity) {
		_bufferList.add(basicActivity);
	}

	public void remove(BaseActivity basicActivity) {
		_bufferList.remove(basicActivity);
	}

	public void clear() {

		for (int i = _bufferList.size() - 1; i > -1; i--) {
			_bufferList.get(i).homeFinish();
			Log.d("clare", _bufferList.get(i).getClass().toString());

		}
		_bufferList.clear();
		System.gc();

	}

}
